package com.example.footballsystem.controller;

import com.example.footballsystem.entity.Master;
import com.example.footballsystem.entity.User;
import com.example.footballsystem.service.MasterService;
import com.example.footballsystem.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/MasterAccount")
@CrossOrigin(origins = "*")
public class MasterController {
    @Autowired
    MasterService masterService;
    //登录
    @GetMapping("/login")
    public ResponseEntity<Boolean> login(String account, String password){
        //log.info(account+" "+password);
        if(masterService.Logincheck(account,password)){
            return ResponseEntity.ok().body(true);
        }
        return ResponseEntity.ok().body(false);
    }
    @PostMapping("/regist")
    public ResponseEntity<?> regist(@RequestBody Master master){
        //log.info("1231123123132");
        //log.info(user.getAccount()+" "+user.getPassword()+" "+user.getusername()+" "+user.getEmail()+" "+user.getPhone());
        if(masterService.regist(master)) {
            return ResponseEntity.ok().body(true);
        }
        else
            return ResponseEntity.ok().body(false);
    }
}
